unit uuid_frame;

{$mode ObjFPC}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, StdCtrls, Dialogs, ExtCtrls, Buttons, Spin,
  SynEdit,  Graphics, uuid;

type

  { TFrameUUID }

  TFrameUUID = class(TFrame)
    cbxUpperCase: TCheckBox;
    cbxHyphen: TCheckBox;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    GroupBox3: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    Button1: TSpeedButton;
    SpinEdit1: TSpinEdit;
    StaticText1: TStaticText;
    SynEdit1: TSynEdit;
    procedure Button1Click(Sender: TObject);
    procedure cbxHyphenChange(Sender: TObject);
    procedure cbxUpperCaseChange(Sender: TObject);
    procedure SpinEdit1Change(Sender: TObject);

  private

  public

  end;

implementation

{$R *.lfm}

{ TFrameUUID }



procedure TFrameUUID.Button1Click(Sender: TObject);
var
  i, num: integer;
  uid: uuid_t;
  str: string;
begin
  SynEdit1.Lines.Clear;
  num := StrToInt(SpinEdit1.Text);
  uuid.uuid_create(uid);
  for i := 1 to num do
  begin
    if cbxHyphen.Checked then
    begin
      if cbxUpperCase.Checked then
        str := UpperCase(uid.NewGuid.ToString(True))
      else
        str := LowerCase(uid.NewGuid.ToString(True));
        SynEdit1.Lines.Add(str);
    end
    else
    begin
      if cbxUpperCase.Checked then
        str := UpperCase(uid.NewGuid.ToString(True)).Replace('-', '')
      else
        str := LowerCase(uid.NewGuid.ToString(True)).Replace('-', '');
        SynEdit1.Lines.Add(str);
    end;
  end;

end;

procedure TFrameUUID.cbxHyphenChange(Sender: TObject);
begin
  Button1.Click;
end;

procedure TFrameUUID.cbxUpperCaseChange(Sender: TObject);
begin
  Button1.Click;
end;

procedure TFrameUUID.SpinEdit1Change(Sender: TObject);
begin
  Button1.Click;
end;


end.
